<div class="header_menu">
    <div class="container">
        <div class="header-nav clearfix">
            <?php echo $this->partial('site/headermenu'); ?>
        </div>
    </div>
</div>
</div>
<div class="container breadcrumbs">
    <a href="<?php echo $this->url('shopfront/default'); ?>"><?php echo $this->translate('首页'); ?></a>
    <span class="sep">/</span><span><?php echo $this->translate('虚拟商品'); ?></span>
</div>
<div class="container">
    <div class="uc-full-box">
        <div class="row">
            <div class="span4">
                <?php echo $this->partial('shopfront/home/left_menu.phtml'); ?>
            </div>
            <div class="span16">
                <div class="xm-line-box uc-box uc-favorite-box">
                    <div class="box-hd">
                        <h3 class="title">
                            <?php echo $this->translate('虚拟商品'); ?>
                        </h3>
                    </div>
                    <div class="box-bd">
                        <?php if ($this->virtual_goods->getTotalItemCount() > 0) { ?>
                        <table class="table table-bordered table-hover" style="margin-top: 15px;">
                            <thead>
                            <tr>
                                <th width="40%"><?php echo $this->translate('商品名称'); ?></th>
                                <th width="30%"><?php echo $this->translate('订单编号'); ?></th>
                                <th width="15%"><?php echo $this->translate('商品数量'); ?></th>
                                <th width="15%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            </thead>
                            <?php foreach ($this->virtual_goods as $goods_value) { ?>
                                <tr>
                                    <td><?php echo $this->escapeHtml($goods_value['goods_name']); ?></td>
                                    <td><?php echo $this->escapeHtml($goods_value['order_sn']); ?></td>
                                    <td><?php echo $this->escapeHtml($goods_value['buy_num']); ?></td>
                                    <td>
                                        <?php
                                        if($goods_value['order_state'] < 20) echo '<font color="red">'.$this->translate('未付款').'</font>';
                                        else {
                                            ?>
                                            <a href="JavaScript:;" onclick="get_virtual_goods(<?php echo $goods_value['order_id']; ?>, <?php echo $goods_value['goods_id']; ?>);"><?php echo $this->translate('获取商品信息'); ?></a>
                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } ?>
                        </table>
                            <div>
                                <?php echo ( count($this->virtual_goods) > 0 ) ? $this->paginationControl($this->virtual_goods, 'Sliding', 'site/dbpage',array('page_url'=>$this->url('frontorder/default/order_page', array('action'=>'virtualGoods')))) : ""; ?>
                            </div>
                            <?php } else { ?>
                                <?php echo $this->translate('暂无虚拟商品！'); ?>
                            <?php } ?>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel"><?php echo $this->translate('虚拟商品信息'); ?></h3>
    </div>
    <div class="modal-body" id="virtual-modal-body" style="padding-left: 50px;">

    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true"><?php echo $this->translate('关闭'); ?></button>
    </div>
</div>

<script>
    function get_virtual_goods(order_id, goods_id) {
        $.post("<?php echo $this->url('frontorder/default', array('action'=>'VirtualGoodsInfo')); ?>",{order_id:order_id, goods_id:goods_id},
            function(data){
                if(data.state == 'true') {
                    var i,html = '';
                    var num;
                    for(i=0; i<data.goods.length; i++) {
                        num = i+1;

                        if(i>0) html += '<hr>';
                        html += '<p style="font-size: 14px;">';
                        html += '<strong><?php echo $this->translate('账号'); ?>('+num+')：</strong>';
                        html += data.goods[i].virtual_goods_account;
                        html += '</p>';
                        html += '<p style="font-size: 14px;">';
                        html += '<strong><?php echo $this->translate('密码'); ?>('+num+')：</strong>';
                        html += data.goods[i].virtual_goods_password;
                        html += '</p>';

                    }
                    $('#virtual-modal-body').html(html);
                    $('#myModal').modal('show');
                } else {
                    alert(data.message);
                    return false;
                }
            }, 'json');
    }
</script>